#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QGraphicsItem>
#include <QGraphicsView>
#include <QMainWindow>
#include <QUndoCommand>
#include "property/qtpropertymanager.h"
#include "property/qtvariantproperty.h"
#include "property/qttreepropertybrowser.h"
#include "fileeditfactory.h"
#include "gwscene.h"
#include "GraphicsType.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void refreshProperty(QtProperty *item);
    void propertyInit(QtTreePropertyBrowser *treepro);
    void setPropertyTree(QtTreePropertyBrowser *treepro);
    void createNewScene();

public slots:
    void newfile(bool checked);
    void savefile(bool checked);
    void propertyChanged(QtProperty *property, const QVariant &val);
    void propertyQStringChanged(QtProperty *property, const QVariant &val);
    void sceneSelectionChanged();

private slots:
    void on_rect_new_triggered();

    void on_undo_triggered();

    void on_redo_triggered();

    void on_border_top_triggered();

    void on_border_bottom_triggered();

    void on_align_left_triggered();

    void on_align_right_triggered();

    void on_file_open_triggered();

    void on_file_new_triggered();

    void on_ds_new_triggered();

    void on_string_new_triggered();

private:
    Ui::MainWindow *ui;
    QList<QtProperty*> m_propertys;
//    QList<QtStringPropertyManager *>

    QMap<QtProperty*,QString> m_property_dic;
    QtVariantPropertyManager* m_pVarManager=NULL;
    QtVariantEditorFactory* m_pVarFactory=NULL;

    QtStringPropertyManager* m_stringManage=NULL;
    fileEditFactory* m_stringFactory=NULL;

    QString backgroundFile;
    QString lastFile;

    QGraphicsPixmapItem *background=NULL;
    QUndoStack *m_undoStack = nullptr;
    QGraphicsView *view = nullptr;
    GwScene *scene = nullptr;

    // QWidget interface
protected:
    void resizeEvent(QResizeEvent *event);

signals:
    void setGraphicsState(GraphicsState state);

};
#endif // MAINWINDOW_H
